fix(platina): resolve touchscreen, dual panel, charging reboot, battery guard, camera auth, and internal SIM cellular data
- Add patch 0040: cut panel VSP/VSN always-on rails, attach panel follower to Synaptics TCM touch, add Novatek NT36672A touch node, add BOE panel DTS, and extend DVFS up to 1.84/2.2 GHz. - Prevent Qualcomm ABL infinite reboot loop on poweroff while charger connected via standby detection in phone-poweroff.py. - Implement HTTP Basic Auth in camera web preview server with secure digest verification. - Add battery guard daemon and unit tests to maintain SoC between 50% and 65%. - Implement Option 2 for cellular data: disable ZRAM swap to prevent Hexagon DMA fragmentation crash, add modem modules to initfs, enable ModemManager/NetworkManager WWAN packages and services, and add phone-cellular-setup.py CLI utility with unit tests. - Update recipe checksums and verify 109 unit tests and public index boundaries.
This commit is contained in:
@@ -320,7 +320,25 @@ class Audio:
|
||||
self.released.wait(timeout=8)
|
||||
|
||||
|
||||
def make_handler(camera, shutdown, audio=None):
|
||||
def load_auth(path):
|
||||
if not path or not path.exists():
|
||||
return None
|
||||
try:
|
||||
data = json.loads(path.read_text())
|
||||
if not isinstance(data, dict):
|
||||
return None
|
||||
if not data.get('enabled', True):
|
||||
return None
|
||||
user = data.get('username')
|
||||
pwd = data.get('password')
|
||||
if user and pwd:
|
||||
return {'username': str(user), 'password': str(pwd)}
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
|
||||
def make_handler(camera, shutdown, audio=None, auth=None):
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def setup(self):
|
||||
super().setup()
|
||||
@@ -331,6 +349,22 @@ def make_handler(camera, shutdown, audio=None):
|
||||
def log_message(self, *_):
|
||||
pass
|
||||
|
||||
def check_auth(self):
|
||||
if not auth:
|
||||
return True
|
||||
auth_header = self.headers.get('Authorization')
|
||||
if not auth_header or not auth_header.startswith('Basic '):
|
||||
return False
|
||||
try:
|
||||
import base64
|
||||
encoded = auth_header.split(' ', 1)[1].strip()
|
||||
decoded = base64.b64decode(encoded).decode('utf-8')
|
||||
user, pwd = decoded.split(':', 1)
|
||||
return (secrets.compare_digest(user, auth['username']) and
|
||||
secrets.compare_digest(pwd, auth['password']))
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def reply(self, status, content_type, payload):
|
||||
self.send_response(status)
|
||||
self.send_header('Content-Type', content_type)
|
||||
@@ -344,6 +378,14 @@ def make_handler(camera, shutdown, audio=None):
|
||||
self.reply(status, 'application/json', json.dumps(value).encode())
|
||||
|
||||
def do_GET(self):
|
||||
if not self.check_auth():
|
||||
self.send_response(401)
|
||||
self.send_header('WWW-Authenticate', 'Basic realm="Platina Camera"')
|
||||
self.send_header('Content-Type', 'application/json')
|
||||
self.send_header('Cache-Control', 'no-store')
|
||||
self.end_headers()
|
||||
self.wfile.write(json.dumps(dict(error='Authentication required')).encode())
|
||||
return
|
||||
path = urlsplit(self.path).path
|
||||
try:
|
||||
if path == '/':
|
||||
@@ -410,6 +452,14 @@ def make_handler(camera, shutdown, audio=None):
|
||||
self.close_connection = True
|
||||
|
||||
def do_POST(self):
|
||||
if not self.check_auth():
|
||||
self.send_response(401)
|
||||
self.send_header('WWW-Authenticate', 'Basic realm="Platina Camera"')
|
||||
self.send_header('Content-Type', 'application/json')
|
||||
self.send_header('Cache-Control', 'no-store')
|
||||
self.end_headers()
|
||||
self.wfile.write(json.dumps(dict(error='Authentication required')).encode())
|
||||
return
|
||||
path = urlsplit(self.path).path
|
||||
if path not in ('/settings', '/save', '/restore', '/camera', '/audio'):
|
||||
self.json(404, dict(error='Not found'))
|
||||
@@ -458,6 +508,7 @@ def main():
|
||||
parser.add_argument('--frame', type=Path, default=Path('/run/platina-camera/latest.jpg'))
|
||||
parser.add_argument('--capture', default='/usr/lib/platina-camera/bin/platina-camera-capture')
|
||||
parser.add_argument('--config', type=Path, default=Path('/etc/platina-camera/preview.json'))
|
||||
parser.add_argument('--auth-config', type=Path, default=Path('/etc/platina-camera/auth.json'))
|
||||
parser.add_argument('--mqtt-config', type=Path, default=Path('/etc/platina-camera/mqtt.json'))
|
||||
parser.add_argument('--seconds', type=float)
|
||||
args = parser.parse_args()
|
||||
@@ -468,7 +519,8 @@ def main():
|
||||
camera = Camera(args)
|
||||
audio = Audio()
|
||||
bridge = None
|
||||
server = ThreadingHTTPServer((args.listen, args.port), make_handler(camera, shutdown, audio))
|
||||
auth = load_auth(args.auth_config)
|
||||
server = ThreadingHTTPServer((args.listen, args.port), make_handler(camera, shutdown, audio, auth=auth))
|
||||
server.daemon_threads = True
|
||||
server.timeout = .1
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user